package com.tkc.common.exception;

import com.tkc.common.enums.BaseResultCodeEnum;
import com.tkc.common.result.CommonResult;

/**
 * 
 * @Function: 定义响应异常格式
 * 
 * @Project :assessmenttask 
 * @Package :com.tkc.common.exception 
 * @File :ResponseException.java 
 * @ClassName: ResponseException  
 * 
 * @author tankaichao 
 * @email cgztkc@126.com 
 * @Date 2016年8月9日下午6:57:40
 * @since JDK 1.8 
 *
 */
@SuppressWarnings("serial")
public class ResponseException extends RuntimeException {
	private BaseResultCodeEnum exceptionEnums;

	public ResponseException(BaseResultCodeEnum exceptionEnums) {
		this.exceptionEnums = exceptionEnums;
	}

	public BaseResultCodeEnum getExceptionEnums() {
		return exceptionEnums;
	}
	
	public static CommonResult buildException(ResponseException responseException){
		BaseResultCodeEnum enums = responseException.getExceptionEnums();
		CommonResult result = new CommonResult();
		result.setResultCode(enums.getCode());
		result.setResultMsg(enums.getMsg());
		return result;  
	}
}
